<?php

require_once 'Core/Form.php';

class Admin_Form_OpenId extends Core_Form
{
    /**
     * Initialize the form
     *
     * @return void
     */
    public function init()
    {
        parent::init();

        $view = $this->getView();

        // create new element
        $id = $this->createElement('hidden', 'id', array(
            'decorators'    => array('ViewHelper')
        ));

        // create new element
        $openid = $this->createElement('text', 'openid_identifier', array(
            'label'         => $view->getTranslation('OpenID'),
            'required'      => true,
            'filters'       => array('StringTrim'),
// @TODO: add validator for openids
            'attribs'       => array('size'  => 50,
                                     'class' => 'openid_login'),
            'errorMessages' => array('You must enter a valid OpenID.'),
        ));

        $submit = $this->createElement('submit', 'openid_action', array(
            'label'         => $view->getTranslation('Login'),
            'attribs'       => array('class' => 'submit'),
        ));

        // add the elements to the form
        $this->addElement($id)
             ->addElement($openid)
             ->addElement($submit)
             ->addDisplayGroup(array('form_instance', 'id', 'openid_identifier', 'openid_action'),
                                     'adminOpenIdGroup',
                                     array('legend' => $view->getTranslation('OpenID Login'))
             );

        $this->setDecorators(array(
            'FormElements',
            'Form',
        ));

        $this->setDisplayGroupDecorators(array(
            'FormElements',
            'Fieldset',
        ));
    }
}